package com.breaktime1903.stinky_eggs;

import net.minecraftforge.fml.common.Mod;
import net.minecraft.core.registries.Registries;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.item.*;
import net.minecraft.world.item.CreativeModeTab.TabVisibility;
import net.minecraft.world.level.block.Block;
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;

// The value here should match an entry in the META-INF/mods.toml file



@Mod(StinkyEggsMod.MODID)
public class StinkyEggsMod
{
    public static final String MODID = "stinky_eggs_mod";
    // 物品和方块注册器
    private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
    private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID);
    // private static final DeferredRegister<SoundEvent> SOUNDS = DeferredRegister.create(Registries.SOUND_EVENT, MODID);

    public static final RegistryObject<Item> STINKY_EGG_ITEM = ITEMS.register(
        "stinky_egg", 
        () -> new ItemStinkyEgg(new Item.Properties())
    );

    public static final RegistryObject<Item> SUPER_STINKY_EGG_ITEM = ITEMS.register(
        "super_stinky_egg", 
        () -> new ItemSuperStinkyEgg(new Item.Properties())
    );

    public StinkyEggsMod()
    {
        IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
        ITEMS.register(bus);
        BLOCKS.register(bus);
        StinkyEggsSoundEvents.SOUNDS.register(bus);
        bus.addListener(this::addItemToCreativeTabs);
    }
    private void addItemToCreativeTabs(BuildCreativeModeTabContentsEvent event)
    {
        if(event.getTabKey() == CreativeModeTabs.COMBAT)
        {
            event.accept(new ItemStack(STINKY_EGG_ITEM.get()),TabVisibility.PARENT_AND_SEARCH_TABS);
            event.accept(new ItemStack(SUPER_STINKY_EGG_ITEM.get()),TabVisibility.PARENT_AND_SEARCH_TABS);
        }
    };
    
}